package com.chuyu.jzwboa.adapter.notice;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.chuyu.jzwboa.R;

import java.util.List;

/**
 * Created by Administrator on 2017/12/15.
 * 通知公告
 */

public class NoticeAdapter extends RecyclerView.Adapter<NoticeAdapter.Viewholder> {
	private List<Integer> mList;
	private Context mContext;
	private OnItemClickListener onItemClick;

	public NoticeAdapter(Context context, List<Integer> list) {
		this.mContext = context;
		this.mList = list;
	}

	@Override
	public NoticeAdapter.Viewholder onCreateViewHolder(ViewGroup parent, int viewType) {
		View view = LayoutInflater.from(mContext).inflate(R.layout.item_notice, parent, false);
		return new Viewholder(view);
	}

	@Override
	public void onBindViewHolder(Viewholder holder, final int position) {
		if (onItemClick != null) {
			holder.itemView.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View view) {
					onItemClick.onItemClick(view, position);
				}
			});
		}
	}

	@Override
	public int getItemCount() {
		return mList.size();
	}

	public class Viewholder extends RecyclerView.ViewHolder {
		public Viewholder(View itemView) {
			super(itemView);
		}
	}

	public void setOnItemClickListener(OnItemClickListener onItemClick) {
		this.onItemClick = onItemClick;

	}

	interface OnItemClickListener {
		void onItemClick(View view, int position);
	}
}
